<template>
<div>
  <span><strong>学生报名人数—数据报表</strong></span>
  <div ref="Dom" style="width: 620px; height: 320px"></div>
</div>
</template>

<script>
import * as echarts from "echarts";
import { getbmEchartslist } from "@/api/echartsbm/echartsbm";
export default {
  data() {
    return {
      major: null,
      bmsum: null,
    };
  },

  mounted() {
    //获取Dom节点
    let chartDom = this.$refs.Dom;
    //初始化echarts实例
    let myChart = this.$echarts.init(chartDom);
    //绘制图标
    let option;

    const gaugeData = [
      {
        value: null,
        name: "总人数",
        title: {
          color: "blue",
          offsetCenter: ["-160%", "-60%"],
        },
        detail: {
          offsetCenter: ["-160%", "-40%"],
        },
      },
      {
        value: null,
        name: "未报名人数",
        title: {
          color: "green",
           offsetCenter: ["-160%", "0%"],
        },
        detail: {
          offsetCenter: ["-160%", "20%"],
        },
      },
      {
        value: null,
        name: "已报名人数",
        title: {
            color: "black",
           offsetCenter: ["-160%", "60%"],
        },
        detail: {
          offsetCenter: ["-160%", "80%"],
        },
      },
    ];
    option = {
      series: [
        {
          min: 0,
          max: null,
          radius: "96%", //仪表大小
          type: "gauge",
          center: ["55%", "50%"], // 默认全局居中
          anchor: {
            show: true,
            showAbove: true,
            size: 16,
            itemStyle: {
              color: "#FAC858",
            },
          },


          pointer: {
            //指针样式
            icon: "path://M2.9,0.7L2.9,0.7c1.4,0,2.6,1.2,2.6,2.6v115c0,1.4-1.2,2.6-2.6,2.6l0,0c-1.4,0-2.6-1.2-2.6-2.6V3.3C0.3,1.9,1.4,0.7,2.9,0.7z",
            width: 6,
            length: "70%",
            offsetCenter: [0, "8%"],
          },
          progress: {
            show: true,
            overlap: true,
            roundCap: true,
          },
          axisLine: {
            roundCap: true,
          },
          data: gaugeData,
          title: {
            fontSize: 16,
            top: 20,
          },
          detail: {
            width: 40,
            height: 19,
            fontSize: 16,
            color: "#fff",
            backgroundColor: "auto",
            borderRadius: 3,
            formatter: "{value}人",
          },
        },
      ],
    };

    getbmEchartslist().then((response) => {
      // this.data.data=response
      console.log(response.data);
      gaugeData[0].value = response.data[0].totalsum;
      option.series[0].max = response.data[0].totalsum; //仪表盘最大值
      gaugeData[1].value = response.data[0].nobmtotalsum;
      gaugeData[2].value = response.data[0].bmtotalsum;
      // response.data.forEach((item) => {
      // option.xAxis.data.push(item.major);
      // option.xAxis.data = item.major;
      //   console.log(item);
      //   option.series[5].data.push(item);
      // });
      option && myChart.setOption(option);
    });
  },
};
</script>

<style scoped>
span{
   font-size: 18px;
   color: rgb(155, 27, 27);
   position: relative;
   /* left: 690px;
   top: 60px; */
   
}
</style>

